var projectName = "药品销售管理系统"
/**
 * 轮播图配置
 */
var swiper = {
  // 设定轮播容器宽度，支持像素和百分比
  width: "100%",
  height: "400px",
  // hover（悬停显示）
  // always（始终显示）
  // none（始终不显示）
  arrow: "none",
  // default（左右切换）
  // updown（上下切换）
  // fade（渐隐渐显切换）
  anim: "default",
  // 自动切换的时间间隔
  // 默认3000
  interval: 2000,
  // 指示器位置
  // inside（容器内部）
  // outside（容器外部）
  // none（不显示）
  indicator: "outside",
}

/**
 * 个人中心菜单
 */
var centerMenu = [
  {
    name: "个人中心",
    url: "../" + localStorage.getItem("userTable") + "/center.html",
  },
  {
    name: "我的订单",
    url: "../shop-order/list.html",
  },

  {
    name: "我的地址",
    url: "../shop-address/list.html",
  },

  {
    name: "我的收藏",
    url: "../storeup/list.html",
  },
]

var indexNav = [
  {
    name: "药品信息",
    url: "./pages/yaopinxinxi/list.html",
  },

  {
    name: "医药指南",
    url: "./pages/news/list.html",
  },
  {
    name: "留言反馈",
    url: "./pages/messages/list.html",
  },
]

var adminurl = "http://localhost:8080/ssm3j93s/admin/index.html"

var cartFlag = false

var chatFlag = false

cartFlag = true

var menu = [
  {
    backMenu: [
      {
        child: [
          {
            buttons: ["新增", "查看", "修改", "删除"],
            menu: "用户",
            menuJump: "列表",
            tableName: "yonghu",
          },
        ],
        menu: "用户管理",
      },
      {
        child: [
          {
            buttons: ["新增", "查看", "修改", "删除"],
            menu: "员工",
            menuJump: "列表",
            tableName: "yuangong",
          },
        ],
        menu: "员工管理",
      },
      {
        child: [
          {
            buttons: ["新增", "查看", "修改", "删除"],
            menu: "药品类别",
            menuJump: "列表",
            tableName: "yaopinleibie",
          },
        ],
        menu: "药品类别管理",
      },
      {
        child: [
          {
            buttons: ["新增", "查看", "修改", "删除", "查看评论", "导出"],
            menu: "药品信息",
            menuJump: "列表",
            tableName: "yaopinxinxi",
          },
        ],
        menu: "药品信息管理",
      },
      {
        child: [
          {
            buttons: ["查看", "修改", "删除", "导出"],
            menu: "药品入库",
            menuJump: "列表",
            tableName: "yaopinruku",
          },
        ],
        menu: "药品入库管理",
      },
      {
        child: [
          {
            buttons: ["查看", "修改", "删除", "导出"],
            menu: "药品出库",
            menuJump: "列表",
            tableName: "yaopinchuku",
          },
        ],
        menu: "药品出库管理",
      },
      {
        child: [
          {
            buttons: ["查看", "修改", "删除"],
            menu: "在线咨询",
            menuJump: "列表",
            tableName: "zaixianzixun",
          },
        ],
        menu: "在线咨询管理",
      },
      {
        child: [
          {
            buttons: ["查看", "修改", "回复", "删除"],
            menu: "留言板管理",
            tableName: "messages",
          },
        ],
        menu: "留言板管理",
      },
      {
        child: [
          {
            buttons: ["新增", "查看", "修改", "删除"],
            menu: "医药指南",
            tableName: "news",
          },
          {
            buttons: ["新增", "查看", "修改", "删除"],
            menu: "轮播图管理",
            tableName: "config",
          },
        ],
        menu: "系统管理",
      },
      {
        child: [
          {
            buttons: ["查看", "删除"],
            menu: "已取消订单",
            tableName: "orders/已取消",
          },
          {
            buttons: ["查看", "删除", "发货"],
            menu: "已支付订单",
            tableName: "orders/已支付",
          },
          {
            buttons: ["查看", "删除"],
            menu: "已退款订单",
            tableName: "orders/已退款",
          },
          {
            buttons: ["查看", "删除"],
            menu: "已完成订单",
            tableName: "orders/已完成",
          },
          {
            buttons: ["查看", "删除"],
            menu: "已发货订单",
            tableName: "orders/已发货",
          },
          {
            buttons: ["查看", "删除"],
            menu: "未支付订单",
            tableName: "orders/未支付",
          },
        ],
        menu: "订单管理",
      },
    ],
    frontMenu: [
      {
        child: [
          {
            buttons: ["查看"],
            menu: "药品信息列表",
            menuJump: "列表",
            tableName: "yaopinxinxi",
          },
        ],
        menu: "药品信息模块",
      },
    ],
    hasBackLogin: "是",
    hasBackRegister: "否",
    hasFrontLogin: "否",
    hasFrontRegister: "否",
    roleName: "管理员",
    tableName: "users",
  },
  {
    backMenu: [
      {
        child: [
          {
            buttons: ["新增", "查看", "修改", "删除"],
            menu: "在线咨询",
            menuJump: "列表",
            tableName: "zaixianzixun",
          },
        ],
        menu: "在线咨询管理",
      },
      {
        child: [
          {
            buttons: ["查看", "删除"],
            menu: "我的收藏管理",
            tableName: "storeup",
          },
        ],
        menu: "我的收藏管理",
      },
      {
        child: [
          { buttons: ["查看"], menu: "已取消订单", tableName: "orders/已取消" },
          {
            buttons: ["查看"],
            menu: "已支付订单",
            tableName: "orders/已支付",
          },
          { buttons: ["查看"], menu: "已退款订单", tableName: "orders/已退款" },
          {
            buttons: ["查看"],
            menu: "已完成订单",
            tableName: "orders/已完成",
          },
          {
            buttons: ["查看", "确认收货"],
            menu: "已发货订单",
            tableName: "orders/已发货",
          },
          {
            buttons: ["查看"],
            menu: "未支付订单",
            tableName: "orders/未支付",
          },
        ],
        menu: "订单管理",
      },
    ],
    frontMenu: [
      {
        child: [
          {
            buttons: ["查看"],
            menu: "药品信息列表",
            menuJump: "列表",
            tableName: "yaopinxinxi",
          },
        ],
        menu: "药品信息模块",
      },
    ],
    hasBackLogin: "是",
    hasBackRegister: "否",
    hasFrontLogin: "是",
    hasFrontRegister: "是",
    roleName: "用户",
    tableName: "yonghu",
  },
  {
    backMenu: [
      {
        child: [
          {
            buttons: ["查看", "入库", "出库"],
            menu: "药品信息",
            menuJump: "列表",
            tableName: "yaopinxinxi",
          },
        ],
        menu: "药品信息管理",
      },
      {
        child: [
          {
            buttons: ["查看", "修改", "删除"],
            menu: "药品入库",
            menuJump: "列表",
            tableName: "yaopinruku",
          },
        ],
        menu: "药品入库管理",
      },
      {
        child: [
          {
            buttons: ["删除", "修改", "查看"],
            menu: "药品出库",
            menuJump: "列表",
            tableName: "yaopinchuku",
          },
        ],
        menu: "药品出库管理",
      },
      {
        child: [
          {
            buttons: ["查看", "审核"],
            menu: "在线咨询",
            menuJump: "列表",
            tableName: "zaixianzixun",
          },
        ],
        menu: "在线咨询管理",
      },
    ],
    frontMenu: [
      {
        child: [
          {
            buttons: ["查看"],
            menu: "药品信息列表",
            menuJump: "列表",
            tableName: "yaopinxinxi",
          },
        ],
        menu: "药品信息模块",
      },
    ],
    hasBackLogin: "是",
    hasBackRegister: "否",
    hasFrontLogin: "否",
    hasFrontRegister: "否",
    roleName: "员工",
    tableName: "yuangong",
  },
]

var isAuth = function (tableName, key) {
  let role = localStorage.getItem("userTable")
  let menus = menu
  for (let i = 0; i < menus.length; i++) {
    if (menus[i].tableName == role) {
      for (let j = 0; j < menus[i].backMenu.length; j++) {
        for (let k = 0; k < menus[i].backMenu[j].child.length; k++) {
          if (tableName == menus[i].backMenu[j].child[k].tableName) {
            let buttons = menus[i].backMenu[j].child[k].buttons.join(",")
            return buttons.indexOf(key) !== -1 || false
          }
        }
      }
    }
  }
  return false
}

var isFrontAuth = function (tableName, key) {
  let role = localStorage.getItem("userTable")
  let menus = menu
  for (let i = 0; i < menus.length; i++) {
    if (menus[i].tableName == role) {
      for (let j = 0; j < menus[i].frontMenu.length; j++) {
        for (let k = 0; k < menus[i].frontMenu[j].child.length; k++) {
          if (tableName == menus[i].frontMenu[j].child[k].tableName) {
            let buttons = menus[i].frontMenu[j].child[k].buttons.join(",")
            return buttons.indexOf(key) !== -1 || false
          }
        }
      }
    }
  }
  return false
}
